from app import db
from .model import ChannelArticle

class ChannelArticleService:
    """
    保存数据
    """
    def save(channelarticle):
        db.session.add(channelarticle)
        db.session.commit()
        
    '''
    更新数据
    '''
    def update(channelarticle):
        tmp_channelarticle = ChannelArticle.query.get(channelarticle.channel_pk)
        tmp_channelarticle.fk_channel_pk = channelarticle.fk_channel_pk
        tmp_channelarticle.fk_article_pk = channelarticle.fk_article_pk
        db.session.commit()
    
    def delete(channelarticle):
        channelArticle = ChannelArticle.query.get(channelarticle.fk_article_pk)
        db.session.delete(channelArticle)
        db.session.commit()